<template>
  <el-select style="width: 100%" v-model="type" value-key="name" placeholder="请选择事件来源" clearable @change="change">
    <el-option v-for="(item, index) in opts" :key="index" :label="item.label" :value="item.value"></el-option>
  </el-select>
</template>

<script>
export default {
  props: {
    /* Type */
    value: {
      type: [String, Number],
      default: null
    }
  },
  data() {
    return {
      opts: [
        {
          label: '微信上报',
          value: 'WECHAT'
        },
        {
          label: 'AI上报',
          value: 'AI'
        },
        {
          label: '数字城管',
          value: 'SZCG'
        },
        {
          label: '设备上报',
          value: 'DEVICE'
        },
        {
          label: '文明创建办',
          value: 'WMCJB'
        },
      ],
      type: null
    };
  },
  watch: {
    value: {
      handler(val) {
        this.type = val || null;
      },
      immediate: true
    }
  },
  methods: {
    change(e) {
      var user = this.opts.find((item) => item.value == e);
      this.$emit('input', e);
      this.$emit('change', user || {});
    }
  }
};
</script>

<style scoped lang="scss"></style>
